#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
int my_atoi(char* arr)
{
	int i = 0;
	int sign = 1;
	int sum = 0;
	if (*arr == '\0')
	{
		return 0;
	}
	while (*arr == ' ')
	{
		arr++;
	}
	if (*arr == '+')
	{
		sign = 1;
		arr++;
	}
	if (*arr == '-')
	{
		sign = -1;
		arr++;
	}
	for (sum = 0; *arr >= '0' && *arr <= '9';arr++)
	{
		sum = sum * 10 + (*arr-'0');
	}
	return sum*sign;
}
int main()
{
	char* arr= " -123a 123";
	int i = my_atoi(arr);
	printf("%d", i);
	return 0;
}